
package homework_java.eg;
public class Synchronize_Thread implements Runnable { 
     public void run() { 
    	  //������
          synchronized(this) { 
               for (int i = 0; i < 5; i++) { 
                    System.out.println(Thread.currentThread().getName() + " synchronized loop " + i); 
               } 
          } 
     } 
     public static void main(String[] args) { 
          Synchronize_Thread t1 = new Synchronize_Thread(); 
		  //ta��tb��������, synchronize(this)��֤ͬһʱ��һ��ͬһ����顢���������ִ�л����
          Thread ta = new Thread(t1, "A"); 
          Thread tb = new Thread(t1, "B"); 
          ta.start(); 
          tb.start(); 
     }
}